package edu.luc.cs.trull;

import java.beans.PropertyChangeEvent;

/**
 * An abstraction of the capability to execute and control 
 * a component in the proper thread.
 */
public interface ComponentScheduler extends Scheduler {

	/**
	 * This method starts a component and waits until the component is ready.
	 * @param c the component to be started.
	 */
	void start(Component c) throws InterruptedException;

	/**
	 * This method starts a component with the given event
	 * and waits until the component is ready.
	 * @param c the component to be started.
   * @param event the event to be sent to the component.
	 */
	void start(Component c, PropertyChangeEvent event)
			throws InterruptedException;

	/**
	 * This method stops a component and waits until the component has stopped.
	 * @param c the component to be stopped.
	 */
	void stop(Component c) throws InterruptedException;

    /**
     * This method suspends a component and waits until the component has suspended.
     * @param c the component to be suspended.
     */
    void suspend(Component c) throws InterruptedException;

    /**
     * This method resumes a component and waits until the component has resumed.
     * @param c the component to be resumed.
     */
    void resume(Component c) throws InterruptedException;

	/**
	 * This method sends an event to the component and waits 
	 * until the component has processed the event.
   * @param c the component that will receive the event.
   * @param event the event sent to the component.
	 */
	void propertyChange(Component c, PropertyChangeEvent event)
			throws InterruptedException;

	/**
	 * This method waits for the runner to finish processing all pending requests.  
	 * This capability is important for avoiding race conditions.
	 * @throws InterruptedException if the current thread is interrupted 
   * before or while waiting.
	 */
	void await() throws InterruptedException;
}